<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Rep\ReturnedGoodsRep;
use Illuminate\Http\Request;

class ReturnedGoods extends Controller
{
    //退货管理
    protected $rep;

    public function __construct(Request $request)
    {
        $this->rep = new ReturnedGoodsRep();
    }

    /**
     * 获取产品列表
     * product_name
     * color_id
     *
     */
    public function getReturnedGoodsList(Request $request){
        $params = $request->only(['customer_id','product_id','model_number_id','order_number','serial_number']);
        $data = $this->rep->getReturnedGoodsListRep($params);
        return re(0,$data,'success');
    }

    /**
     * 新增退货
     * @param Request $request
     * @return void
     */
    public function addReturnedGoods(Request $request){
        $params = $request->only(['order_id','remark','returned_time','finish_id','returned_position']);
        $data = $this->rep->addReturnedGoodsRep($params);
        return re($data['code'],$data['data'],$data['msg']);
    }

    /**
     * 获取已发货订单列表
     * @return void
     */
    public function getDeliveredOrderList(Request $request){
        $params = $request->only(['logistics_status']);
        $data = $this->rep->getDeliveredOrderListRep($params);
        return re(0,$data,'success');
    }

    public function exchangeGoods(Request $request){
        $params = $request->only(['semi_id','remark','num']);
        $data = $this->rep->exchangeGoodsRep($params);
        return re(0,$data,'success');
    }


}
